define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'sendbillog/index' + location.search,
                    add_url: 'sendbillog/add',
                    edit_url: 'sendbillog/edit',
                    del_url: 'sendbillog/del',
                    multi_url: 'sendbillog/multi',
                    import_url: 'sendbillog/import',
                    table: 'shopro_order_bill_log',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'bill_id', title: __('Bill_id')},
                        {field: 'order_sn', title: __('Order_sn'), operate: 'LIKE'},
                        {field: 'chnltrxid', title: __('Chnltrxid'), operate: 'LIKE'},
                        {field: 'mchId', title: __('Mchid'), operate: 'LIKE'},
                        {field: 'fz_account', title: __('Fz_account'), operate: 'LIKE'},
                        {field: 'fz_number', title: __('Fz_number'), operate: 'LIKE'},
                        {field: 'recharge_order_sn', title: __('Recharge_order_sn'), operate: 'LIKE'},
                        {field: 'recharge_id', title: __('Recharge_id')},
                        {field: 'fen_fee', title: __('Fen_fee'), operate:'BETWEEN'},
                        //{field: 'all_fee', title: __('All_fee'), operate:'BETWEEN'},
                        //{field: 'sup_fee', title: __('Sup_fee'), operate:'BETWEEN'},
                        {field: 'fen_sn', title: __('Fen_sn'), operate: 'LIKE'},
                        {field: 'is_success', title: '分账结果', searchList: {"0":__('Is_success 0'),"1":__('Is_success 1')}, formatter: Table.api.formatter.normal},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'is_check', title: __('Is_check'), searchList: {"0":__('Is_check 0'),"1":__('Is_check 1')}, formatter: Table.api.formatter.normal},
                        {field: 'is_send', title: __('Is_send'), searchList: {"0":__('Is_send 0'),"1":__('Is_send 1')}, formatter: Table.api.formatter.normal},
                        {field: 'req_json', title: __('请求结果'), operate:'BETWEEN'},

                        {field: 'check_json', title: __('检测结果'), operate:'BETWEEN'},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
